﻿<%
Class Cls_Form

	Dim vID
	Dim vName
	Dim vStatus
	Dim vDateTime
	Dim LastError

	Private Sub Class_Initialize()
		Call ChkLogin("login")
		Call Initialize()
	End Sub

	Private Sub Class_Terminate()
		Call Initialize()
	End Sub

	Public Function Initialize()
		vID = 0
		vName = ""
		vStatus = 1
		vDateTime = Now()
	End Function

	Public Function GetValue()
		vName = Trim(Request.Form("oName"))
		vStatus = Request.Form("oStatus")
		If Len(vName) < 1 Or Len(vName) > 50 Then LastError = "方案名称的长度请控制在 1 至 50 位" : GetValue = False : Exit Function
		GetValue = True
	End Function

	Public Function SetValue()
		Dim Rs
		Set Rs = DB("Select * From [{pre}UserForm] Where [ID]=" & vID,1)
		If Rs.Eof Then Rs.Close : Set Rs = Nothing : LastError = "你所需要查询的记录 " & vID & " 不存在!" : SetValue = False : Exit Function
		vName = Rs("Name")
		vStatus = Rs("Status")
		vDateTime = Rs("DateTime")
		SetValue = True
	End Function

	Public Function Create()
	
  		dim t1:t1=timer()
	
		Dim Rs
		Set Rs = DB("Select * From [{pre}UserForm]",3)
		Rs.addnew
		Rs("Name") = vName
		Rs("Status") = vStatus
		Rs("DateTime") = Now()
		Rs.Update : Rs.Close
		Set Rs = Nothing

		Create = True
		
		'response.write formatnumber((timer()-t1),5)
		'response.end
	End Function

	Public Function Modify()
		Dim Rs,DelOldData,DelID
		Set Rs = DB("Select * From [{pre}UserForm] Where [ID]=" & vID,3)
		If Rs.Eof Then Rs.Close : Set Rs = Nothing : LastError = "你所需要更新的记录 " & vID & " 不存在!" : Modify = False : Exit Function
		Rs("Name") = vName
		Rs("Status") = vStatus
		Rs("DateTime") = now()
		Rs.Update : Rs.Close
		Modify = True
	End Function

	Public Function Delete()
		Call SetValue()
		Call DB("Delete From [{pre}UserForm] Where [ID]=" & vID ,0) '# 删除信息
		Delete = True
	End Function
	
End Class
%>